<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

use App\Http\Controllers\Strator\StratorLoginController;
use App\Http\Controllers\Strator\StratorController;
use App\Http\Controllers\Strator\StratorDepartmentController;
use App\Http\Controllers\Strator\StratorPositionController;
use App\Http\Controllers\Strator\StratorPermissionController;
use App\Http\Controllers\Strator\StratorPositionAuthController;
use App\Http\Controllers\Strator\StratorSupplierController;
use App\Http\Controllers\Strator\StratorCustomerController;
use App\Http\Controllers\Strator\StratorAuthController;
use App\Http\Controllers\Strator\StratorPasswordController;
use App\Http\Controllers\Strator\StratorLoginLogController;
use App\Http\Controllers\Strator\StratorProductTypeController;
use App\Http\Controllers\Strator\StratorProductSpecController;
use App\Http\Controllers\Strator\StratorProductAttrController;
use App\Http\Controllers\Strator\StratorProductController;
use App\Http\Controllers\Strator\StratorProController;
use App\Http\Controllers\Strator\StratorInventoryController;
use App\Http\Controllers\Strator\StratorCheckController;
use App\Http\Controllers\Strator\StratorPurchaseController;

//
Route::middleware(['throttle:strator.login'])->post('strator/login', [StratorLoginController::class,'login']);


Route::middleware(['strator.auth'])->group(function (){
    //
    Route::post('strator/info', [StratorLoginController::class,'loginStratorInfo']);
    //
    Route::post('strator/logout', [StratorLoginController::class,'logout']);
    //
    Route::post('strator/reset/own/password', [StratorPasswordController::class,'resetOwnPassword']);

    //
    Route::prefix('strator')->group(function (){
        //
        Route::controller(StratorController::class)->group(function (){
            //
            Route::post('list', 'index');
            Route::post('add', 'store');
            Route::post('detail', 'show');
            Route::post('modify', 'update');
            Route::post('delete', 'destroy');
            Route::post('password/modify', 'resetPassword');
        });
        //login log
        Route::post('login/log/list', [StratorLoginLogController::class,'index']);

        //
        Route::prefix('auth')->controller(StratorAuthController::class)->group(function (){
            //
            Route::post('permission', 'authPermissions');
            Route::post('direct/permission/ids', 'directPermissionIds');
            Route::post('direct/permission', 'directPermissions');
            //
            Route::post('position', 'authPositions');
            Route::post('own/position/ids', 'hasPositionIds');
            Route::post('position/permission/ids', 'positionPermissionIds');
            Route::post('position/permission', 'positionPermissions');
            //
            Route::post('all/permission/ids', 'allPermissionIds');
            Route::post('all/permission', 'allPermissions');

        });

        //
        Route::prefix('permission')->controller(StratorPermissionController::class)->group(function (){
            //
            Route::post('tree/all', 'allInTree');
            Route::post('tree/own', 'ownInTree');
            //
            Route::post('list', 'index');
            Route::post('add', 'store');
            Route::post('detail', 'show');
            Route::post('modify', 'update');
            Route::post('delete', 'destroy');
        });

        //
        Route::prefix('department')->controller(StratorDepartmentController::class)->group(function (){
            //
            Route::post('tree/all', 'allInTree');
            Route::post('list', 'index');
            Route::post('listwithuser', 'listwithuser');
            Route::post('add', 'store');
            Route::post('detail', 'show');
            Route::post('modify', 'update');
            Route::post('delete', 'destroy');
        });

        //
        Route::prefix('position')->group(function (){
            //
            Route::controller(StratorPositionController::class)->group(function (){
                //
                Route::post('tree/all', 'allInTree');
                Route::post('list', 'index');
                Route::post('add', 'store');
                Route::post('detail', 'show');
                Route::post('modify', 'update');
                Route::post('delete', 'destroy');
            });
            //
            Route::prefix('auth')->controller(StratorPositionAuthController::class)->group(function (){
                //
                Route::post('permission', 'authPermission');
                Route::post('own/permissionIds', 'hasPermissionIds');
                Route::post('own/permission', 'hasPermission');
            });
        });

        // 供应商表
        Route::prefix('supplier')->controller(StratorSupplierController::class)->group(function (){
            //
            Route::post('list', 'index');
            Route::post('add', 'store');
            Route::post('detail', 'show');
            Route::post('modify', 'update');
            Route::post('delete', 'destroy');
        });

        // 客户表
        Route::prefix('customer')->controller(StratorCustomerController::class)->group(function (){
            //
            Route::post('list', 'index');
            Route::post('add', 'store');
            Route::post('detail', 'show');
            Route::post('modify', 'update');
            Route::post('delete', 'destroy');
        });

        // 产品类型表
        Route::prefix('product/type')->controller(StratorProductTypeController::class)->group(function (){
            //
            Route::post('tree/all', 'allInTree');
            Route::post('list', 'index');
            Route::post('add', 'store');
            Route::post('detail', 'show');
            Route::post('modify', 'update');
            Route::post('delete', 'destroy');
        });

        // 产品规格表
        Route::prefix('product/spec')->controller(StratorProductSpecController::class)->group(function (){
            //
            Route::post('tree/all', 'allInTree');
            Route::post('list', 'index');
            Route::post('add', 'store');
            Route::post('detail', 'show');
            Route::post('modify', 'update');
            Route::post('delete', 'destroy');
        });

        // 产品属性表
        Route::prefix('product/attr')->controller(StratorProductAttrController::class)->group(function (){
            //
            Route::post('tree/all', 'allInTree');
            Route::post('list', 'index');
            Route::post('add', 'store');
            Route::post('detail', 'show');
            Route::post('modify', 'update');
            Route::post('delete', 'destroy');
        });

        // 产品主表
        Route::prefix('pro')->controller(StratorProController::class)->group(function (){
            //
            Route::post('list', 'index');
            Route::post('listall', 'listall');
            Route::post('add', 'store');
            Route::post('detail', 'show');
            Route::post('modify', 'update');
            Route::post('delete', 'destroy');
            Route::post('inventory', 'inventory');
            Route::post('warning', 'warning');
        });

        // 产品sku表
        Route::prefix('product')->controller(StratorProductController::class)->group(function (){
            //
            Route::post('list', 'index');
            Route::post('listall', 'listall');
            Route::post('add', 'store');
            Route::post('detail', 'show');
            Route::post('modify', 'update');
            Route::post('delete', 'destroy');
            Route::post('inventory', 'inventory');
            Route::post('inventory/total', 'inventoryTotal');
            Route::post('warning', 'warning');
            Route::post('exportproduct', 'exportproduct');
            Route::post('getBatchList', 'getBatchList');
        });

        // 出入库表
        Route::prefix('inventory')->controller(StratorInventoryController::class)->group(function (){
            //
            Route::post('list', 'index');
            Route::post('add', 'store');
            Route::post('detail', 'show');
            Route::post('modify', 'update');
            Route::post('delete', 'destroy');
            Route::post('getItem', 'getItem');
            Route::post('getItemById', 'getItemById');
            Route::post('exportinventory', 'exportinventory');
        });

        // 盘点列表
        Route::prefix('check')->controller(StratorCheckController::class)->group(function (){
            //
            Route::post('list', 'index');
            Route::post('add', 'store');
            Route::post('detail', 'show');
            Route::post('modify', 'update');
            Route::post('delete', 'destroy');
            Route::post('getchecktime', 'getchecktime');
        });

        // 采购单表
        Route::prefix('purchase')->controller(StratorPurchaseController::class)->group(function (){
            //
            Route::post('list', 'index');
            Route::post('add', 'store');
            Route::post('detail', 'show');
            Route::post('modify', 'update');
            Route::post('delete', 'destroy');
            Route::post('getItem', 'getItem');
        });


    });


});


